<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ktgu
 * Date: 12-9-5
 * Time: 下午8:11
 * To change this template use File | Settings | File Templates.
 */
class AvatarController extends Controller
{
    public $layout = '//layouts/column2';

    public function filters()
    {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }

    /**
     * Specifies the access control rules.
     * This method is used by the 'accessControl' filter.
     * @return array access control rules
     */
    public function accessRules()
    {
        return array(
            array('allow', // allow all users to perform 'index' and 'view' actions
                'actions' => array('update'),
                'users' => array('*'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }

    /**
     * @param string $m 更新头像的几种方式: a:高级模式, t:传统模式, s:从微薄同步的模式
     */
    public function actionUpdate($m = 'a')
    {
        $viewName = 'update-';
        switch ($m) {
            case 't':
                $viewName = $viewName . 'traditional';
                break;
            case 's':
                $viewName = $viewName . 'sync';
                break;
            case 'a':
            default:
                $viewName = $viewName . 'advanced';
                break;
        }

        $this->render('../user/avatar/'.$viewName);
    }

}
